import * as Vuex from 'vuex'
import getters from './getters'


const modulesFiles =
    import.meta.glob('./modules/**/*.js', { eager: true });

let modules = {};
for (const path in modulesFiles) {
    // let pathArr = path.split('/')
    // const moduleName = pathArr[pathArr.length - 1].split('.')[0];
    const moduleName = path.replace(/(.*\/)*([^.]+).*/ig, "$2");
    // console.log('Vuex4', moduleName, modulesFiles[path].default)
    modules[moduleName] = modulesFiles[path].default;
}

const store = Vuex.createStore({
    modules,
    getters,
})

export default store